﻿using System;
using System.Collections.Generic;
using DAL;
using Model;

namespace BLL.MaterialBLL
{
    public class MaterialBLL
    {
        private MaterialRepository _materialRepository = new MaterialRepository();

        // 查询所有材料
        public List<Material> GetAllMaterials()
        {
            return _materialRepository.GetAllMaterials();
        }

        // 查询单个材料
        public Material GetMaterialById(int materialId)
        {
            return _materialRepository.GetMaterialById(materialId);
        }

        // 获取去重的物料类型
        public List<string> GetDistinctMaterialTypes()
        {
            return _materialRepository.GetDistinctMaterialTypes();
        }

        // 根据物料类型获取去重的详细类型
        public List<string> GetDistinctDetailedTypes(string materialType)
        {
            return _materialRepository.GetDistinctDetailedTypes(materialType);
        }

        // 根据条件筛选材料
        public List<Material> SearchMaterials(string materialType, string detailedType, int? materialId)
        {
            return _materialRepository.SearchMaterials(materialType, detailedType, materialId);
        }

        // 添加材料
        public int AddMaterial(Material material)
        {
            return _materialRepository.AddMaterial(material);
        }
        // 删除材料
        public int DeleteMaterial(int materialId)
        {
            return _materialRepository.DeleteMaterial(materialId);
        }
        public int UpdateMaterial(Material material)
        {
            return _materialRepository.UpdateMaterial(material);
        }
        // 新增：获取物料历史记录
        public List<Material.History> GetMaterialHistory(int materialId, string changeType = null)
        {
            return _materialRepository.GetMaterialHistory(materialId, changeType);
        }

        // 新增：获取所有删除记录
        public List<Material.History> GetAllDeletedMaterials()
        {
            return _materialRepository.GetAllDeletedMaterials();
        }
    }
}